#include <iostream>
#include <gflags/gflags.h>
#include "etcd.hpp"
#include <thread>
#include "./../../../common/log.hpp"


DEFINE_bool(run_mode, false, "程序运行模式 false-调试 true-发布");
DEFINE_string(log_file, "log.txt", "发布模式下 输出文件的，文件名");
DEFINE_int32(log_level, 0 , "日志等级");

const std::string host = "http://127.0.0.1:2379";

void online(const std::string& key, const std::string& val)
{
    DEBUG_LOG("line-上线服务{}-{}", key, val);
}

void offline(const std::string& key, const std::string& val)
{
    DEBUG_LOG("line-下线服务{}-{}", key, val);
}


int main(int argc, char* argv[])
{
    google::ParseCommandLineFlags(&argc, &argv, true);
    init_logger(FLAGS_run_mode, FLAGS_log_file, FLAGS_log_level);

    Discovery::ptr  pclient = make_shared<Discovery>(host,"/service", online, offline);

    std::this_thread::sleep_for(std::chrono::seconds(100));

    return 0;
}